<?php
namespace app\index\controller;

use app\index\model\Contentmodel;
use think\App;
use think\facade\View;

class Detail extends Common
{
    protected $contentmodel;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->contentmodel = new Contentmodel();
    }

    public function index(){
        $id = $this->request->request('id');
        //记录文章访问量
        parent::index();
        $this->contentmodel->setPageviewById($id);
        $this->showData['detailInfo'] = $this->contentmodel->findDetaiById('id, title, content, create_date, tags', $id);
        $tags = explode(',', $this->showData['detailInfo']['tags']);
        $this->showData['tagList'] = $this->contentmodel->getTags('id, title', [['id', 'in', $tags]]);
        View::assign($this->showData);
        return view();
	}
}
